Skip to content

feat:Hierarchical Knowledge Aggregation for Graphify#264

Open
ljinshuan wants to merge 86 commits into
Graphify-Labs:v4from
ljinshuan:feature/team_version
Open

feat:Hierarchical Knowledge Aggregation for Graphify#264
ljinshuan wants to merge 86 commits into
Graphify-Labs:v4from
ljinshuan:feature/team_version

Conversation

@ljinshuan

@ljinshuan ljinshuan commented Apr 12, 2026

Copy link
Copy Markdown
Contributor

Close #265

Hierarchical Knowledge Aggregation for Graphify

Issue Origin: Single flat knowledge graph cannot represent hierarchical project structure. Large-scale codebases need layered knowledge with bottom-up aggregation and intelligent query routing.

1. Problem Statement: Why Hierarchical Knowledge Aggregation?

Graphify originally supported only a single flat knowledge graph — all source files (code, docs, images) are extracted, merged into one graph.json, and served via MCP as a flat graph.

This reveals three core problems in large-scale projects:

  1. Information Overload 🤯: A 500+ file project produces a graph with thousands of nodes. LLM query token budgets are wasted on irrelevant details, and key architectural information is buried.

  2. Lack of Abstraction Levels 🏗️: Microservice architectures are naturally hierarchical (services → domains → system), but flat graphs cannot represent this. Asking "what is the system architecture?" vs. "how does auth function call work?" requires completely different abstraction levels.

  3. Inefficient Queries 🐌: Every query searches the entire graph, unable to leverage hierarchical structure to narrow scope.

Core Insight: Knowledge should be layered like geographic maps — bottom layers are street-level detail, upper layers are city-level overviews. Upper layer graph = own content + lower layer summary, forming a strict layered DAG.

Minidoracat and others added 30 commits April 8, 2026 19:39
* fix: git hooks fail when graphify is installed via pipx

When installed via pipx, the graphify module is only available in
pipx's isolated venv, not the system python3. The git hooks
(post-commit, post-checkout) hardcoded `python3` which cannot import
graphify in this case.

Detect the correct Python interpreter from the graphify binary's
shebang line, matching the approach already used in skill.md Step 1.
Falls back to python3 for system installs.

* fix: handle env-style shebangs and improve interpreter detection

- Use POSIX `command -v` instead of non-standard `which`
- Parse `#!/usr/bin/env python3` shebangs correctly (previous
  `tr -d ' '` would produce `/usr/bin/envpython3`)
- Add import validation fallback to python3 if resolved interpreter
  cannot import graphify
… buffer

* fix: suppress graspologic ANSI output that breaks PowerShell scrolling

graspologic's leiden() emits ANSI escape sequences (progress bars,
colored warnings) that corrupt PowerShell 5.1's scroll buffer on
Windows, disabling vertical scrolling. Redirect stdout/stderr to
StringIO during leiden() calls to prevent any escape codes from
reaching the terminal.

Add 2 tests verifying cluster() produces no stdout/stderr output.

Fixes Graphify-Labs#19

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* docs: add PowerShell troubleshooting section to Windows skill

Document the PowerShell 5.1 scrolling issue and provide 4
workarounds: upgrade graphify, use Windows Terminal, reset
terminal, or uninstall graspologic to use Louvain fallback.

Fixes Graphify-Labs#19

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
- Register 'trae' and 'trae-cn' in _PLATFORM_CONFIG (skill-trae.md,
  ~/.trae/skills/ and ~/.trae-cn/skills/, claude_md=False)
- Add CLI subcommands: graphify trae install/uninstall,
  graphify trae-cn install/uninstall (routes to _agents_install/uninstall)
- Update help text with new platform entries
- Create skill-trae.md (Agent-tool based extraction, AGENTS.md integration,
  no PreToolUse hook support per Trae limitations)
- Update README.md and README.zh-CN.md with Trae platform docs

Co-authored-by: lijinshuan <lijinshuan@bytedance.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…utput

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…y-Labs#109: extension drift, click detection, skill coverage, .graphify_python persistence

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ify-Labs#126)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…e relations in innerHTML (#sec)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…y-Labs#127)

Tree-sitter resolves call targets directly from source — marking them
INFERRED was incorrect. Cross-file class-level uses edges remain INFERRED.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…AST calls

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…Windows git hooks (Graphify-Labs#140)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…hify-Labs#105)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
safishamsi and others added 3 commits April 12, 2026 18:48
Some MCP clients send blank lines between JSON messages. The stdio
transport tried to parse every line as JSONRPCMessage, crashing with
a Pydantic ValidationError. _filter_blank_stdin() installs an OS-level
pipe that relays stdin while silently dropping blank-only lines.

Closes Graphify-Labs#201

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@ljinshuan ljinshuan changed the title Feature/team version feat:Hierarchical Knowledge Aggregation for Graphify Apr 12, 2026
safishamsi and others added 4 commits April 12, 2026 20:49
safishamsi and others added 12 commits April 13, 2026 08:39
…s, fixes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… path bug, .graphifyignore subfolder patterns; v0.4.10: Dart, Hermes, 6 CLI commands, PHP improvements

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…NTS.md python3 fix

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…e plugin, cache root, PHP missing edges, Windows stability, cross-file calls

- Graphify-Labs#352: add skill-kiro.md to pyproject.toml package-data
- Graphify-Labs#341: guard edge_betweenness at >5000 nodes; use approximate k=100 for suggest_questions on large graphs
- Graphify-Labs#354/Graphify-Labs#229: add Step 6b in skill.md to call to_wiki() when --wiki given (before Step 9 cleanup)
- Graphify-Labs#356: call _install_opencode_plugin() from install --platform opencode path
- Graphify-Labs#350: add cache_root param to extract() so subdirectory runs keep cache at ./graphify-out/cache/
- Graphify-Labs#230: PHP class_constant_access_expression emits references_constant edges
- Graphify-Labs#232: PHP scoped_call_expression (static method calls) emits calls edges
- Graphify-Labs#287: os.replace fallback for Windows WinError 5; graphify update exits 1 on failure; templates use graphify update . instead of python3 -c
- Graphify-Labs#348: cross-file call resolution for all languages via raw_calls + global label map pass in extract()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…js, macOS watch, god_nodes degree rename

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
safishamsi and others added 2 commits April 16, 2026 07:01
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- pyproject.toml: keep both pyyaml (ours) and tree-sitter-verilog (theirs)
- __main__.py: keep --layers query routing (ours) + upstream's try/except
  error handling for graph loading
- aggregate.py: fix god_nodes() key change (edges → degree) from upstream

Ref: Graphify-Labs#263
@ljinshuan

Copy link
Copy Markdown
Contributor Author

👋 Friendly reminder — this PR has been sitting here for a while and we've already resolved merge conflicts multiple times to keep it in sync with upstream/v4.

At this point, we'd really appreciate a decision on whether this feature aligns with the project's direction:

If this is something you want — a quick review and merge would be amazing. The feature is ready and has been kept up-to-date through multiple conflict resolutions.

If this isn't the right fit — no hard feelings at all! Just let us know and we'll gladly close this PR to keep the backlog clean.

Either way, a response would be greatly appreciated so we can stop burning cycles on conflict resolution and move forward. 🙏

Thanks for your time!

#265

@3esmit

3esmit commented Apr 20, 2026

Copy link
Copy Markdown

I would double on that. I am unable to use graphify due my vault having too many files. I can however run graphify multiple times in different levels, but that breaks the main proposal of the project.

@ljinshuan

Copy link
Copy Markdown
Contributor Author

I would double on that. I am unable to use graphify due my vault having too many files. I can however run graphify multiple times in different levels, but that breaks the main proposal of the project.

#425 (comment) 。 This issue aims to solve similar problems. The author mentioned in this issue that this feature is included in the v5.0 roadmap. We can look forward to it. @safishamsi

@yongquan-huang

Copy link
Copy Markdown

Is this feature available now? If so, how do I use it? Also, does it support dynamic updates, such as when I add a new microservice?

@shahshubh

shahshubh commented Jun 14, 2026

Copy link
Copy Markdown

Is this feature available now or is no longer in the roadmap? This is a much needed feature so been waiting...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Hierarchical Knowledge Aggregation — layered DAG build, multi-strategy summarization, and intelligent query routing

9 participants